home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 43.zip / Sources C - WorkDisk II.adf / sin1.c < prev    next >
C/C++ Source or Header  |  1987-01-02  |  3KB  |  167 lines

  1. #include "exec/types.h"
  2. #include "intuition/intuition.h"
  3. #include "math.h"
  4.  
  5. struct IntuitionBase *IntuitionBase;
  6. struct Window *NoBorder;
  7. struct GfxBase *GfxBase;
  8. struct RastPort *r;
  9. struct Screen *Scrn;
  10. struct IntuiMessage *mesg;
  11.  
  12. #define INTUITION_REV 29
  13. #define GRAPHICS_REV 29
  14.  
  15. main()
  16. {
  17.  ULONG flags,mclass;
  18.  SHORT x,y,w,h,d,c0,c1,factor,k;
  19.  USHORT mode;
  20.  VOID OpenALL();
  21.  register double i, j;
  22.  
  23.  OpenALL();
  24.  
  25.  /* ======Open een hires custom screen====== */
  26.  
  27.  y=0;
  28.  w=640;
  29.  h=400;
  30.  d=4;
  31.  c0=0x00;
  32.  c1=0x01;
  33.  mode=HIRES;
  34.  
  35.  Scrn=(struct Screen *)
  36.          make_screen(y,w,h,d,c0,c1,mode,NULL);
  37.  
  38.  /* ======open een borderless window ====== */
  39.  
  40.  x=y=0;
  41.  w=640;
  42.  h=200;
  43.  flags = ACTIVATE|SMART_REFRESH|BORDERLESS;
  44.  NoBorder=(struct Window *)
  45.              make_window(x,y,w,h,NULL,flags,Scrn);
  46.  
  47.  /* ======zetten van colorregisters====== */
  48.  
  49.   SetRGB4(ViewPortAddress(NoBorder),0,0,0,0);
  50.   SetRGB4(ViewPortAddress(NoBorder),1,15,15,15);  /* pen 1 wit  */
  51.  
  52.  r=NoBorder->RPort;
  53.  SetAPen(r,1);
  54.  factor = 50; /* amplitude */
  55.  
  56.  for(i=0;i<640;i++)
  57.   {
  58.    j=factor*sin((double)i*0.0174533);
  59.    for(k=0;k<100;k=+4)
  60.    WritePixel(r,(long)i,(long)j+51+k);
  61.   }
  62.  
  63.  
  64.  
  65.  /* ======Close de windows in volgorde====== */
  66.  
  67.  Wait(1<<NoBorder->UserPort->mp_SigBit);
  68.  
  69.  while((mesg=(struct IntuiMessage *)
  70.      GetMsg(NoBorder->UserPort))!=NULL)
  71.   {
  72.    mclass=mesg->Class;
  73.    ReplyMsg(mesg);
  74.   }
  75.   if(mclass==MOUSEBUTTONS || mclass==WINDOWCLOSE)
  76.    {
  77.      CloseWindow(NoBorder);
  78.      CloseScreen(Scrn);
  79.  
  80.    }
  81. }
  82.  
  83. VOID OpenALL()
  84. {
  85.  /*==Intuition==*/
  86.  
  87.  IntuitionBase=(struct IntuitionBase *)
  88.             OpenLibrary("intuition.library",INTUITION_REV);
  89.  
  90.  if(IntuitionBase==NULL)
  91.     exit(FALSE);
  92.  
  93.  /*==Graphics Library==*/
  94.  
  95.  GfxBase=(struct GfxBase *)
  96.           OpenLibrary("graphics.library",GRAPHICS_REV);
  97.  
  98.  if(GfxBase==NULL)
  99.     exit(FALSE);
  100. }
  101.  
  102. make_window(x,y,w,h,name,flags,screen)
  103. SHORT x,y,w,h;
  104. UBYTE *name;
  105. ULONG flags;
  106. struct Screen *screen;
  107.  
  108. {
  109.  struct NewWindow NewWindow;
  110.  
  111.  NewWindow.LeftEdge = x;
  112.  NewWindow.TopEdge = y;
  113.  NewWindow.Width = w;
  114.  NewWindow.Height = h;
  115.  NewWindow.DetailPen = -1;
  116.  NewWindow.BlockPen = -1;
  117.  NewWindow.Title = name;
  118.  NewWindow.Flags = flags;
  119.  NewWindow.IDCMPFlags = CLOSEWINDOW|MOUSEBUTTONS;
  120.  NewWindow.Type = CUSTOMSCREEN;
  121.  NewWindow.FirstGadget = NULL;
  122.  NewWindow.CheckMark = NULL;
  123.  NewWindow.Screen = screen;
  124.  NewWindow.BitMap = NULL;
  125.  NewWindow.MinWidth = 0;
  126.  NewWindow.MinHeight = 0;
  127.  NewWindow.MaxWidth = 0;
  128.  NewWindow.MaxHeight = 0;
  129.  
  130.  return(OpenWindow(&NewWindow));
  131.  
  132. }
  133.  
  134.  
  135.  
  136. make_screen(y,w,h,d,color0,color1,mode,name)
  137. SHORT y,w,h,d;
  138. UBYTE color0,color1,*name;
  139. USHORT mode;
  140. {
  141.  struct NewScreen NewScreen;
  142.  
  143.  NewScreen.LeftEdge = 0;
  144.  NewScreen.TopEdge = y;
  145.  NewScreen.Width = w;
  146.  NewScreen.Height = h;
  147.  NewScreen.Depth = d;
  148.  NewScreen.DetailPen = color0;
  149.  NewScreen.BlockPen = color1;
  150.  NewScreen.ViewModes = mode;
  151.  NewScreen.Type = CUSTOMSCREEN;
  152.  NewScreen.Font = NULL;
  153.  NewScreen.DefaultTitle = name;
  154.  NewScreen.Gadgets = NULL;
  155.  NewScreen.CustomBitMap = NULL;
  156.  
  157.  return(OpenScreen(&NewScreen));
  158. }
  159.  
  160. tekenpixel(col,rast,s,t)
  161. long col,s,t;
  162. struct RastPort *rast;
  163. {
  164.  
  165. }
  166.  
  167.